package com.hnqcgczy.gp.service;

import com.hnqcgczy.gp.dao.IUserDao;
import com.hnqcgczy.gp.dao.UserDaolmpl;
import com.hnqcgczy.gp.db.MyTransaction;
import com.hnqcgczy.gp.vo.TUser;

import java.sql.SQLException;

class UserServiceImpl implements IUserServuce{
    @Override
    public boolean register(String username, String password) throws SQLException {

        return false;
    }

    @Override
    public TUser login(String username, String password, int role) throws SQLException {
        //1·打开数据库连接
        //2·设置事务:手动   自动
        MyTransaction myTransaction = new MyTransaction(true);
        //3·执行业务(组合dao原子操作)
        IUserDao userDao = new UserDaolmpl(myTransaction);
        TUser tUser = userDao.login(username, password, role);
        //       if (tUser.getTuId()!=null){
        //           System.out.println("登录成功");
        //  }


        //4·关闭数据库连接

        return tUser;
    }
}
